<template>
  <div class="denglu">
    <div class="top">面经登录</div>

    <!-- 大盒子 -->
    <div class="zhong">
      <!-- 账号 -->
      <div class="name">
        <!-- 左侧用户名 -->
        <div class="name1">用户名</div>
        <div class="right">
          <!-- 输入框 -->
          <input class="txt" type="text" placeholder="用户名" text="username" />
          <!-- 提示 -->
          <div class="de">xxxxxx</div>
        </div>
      </div>
      <!-- 密码 -->
      <div class="pass">
        <!-- 左侧用户名 -->
        <div class="pass1">密码</div>
        <div class="right">
          <!-- 输入框 -->
          <input
            class="txt"
            type="password"
            placeholder="密码"
            text="password"
          />
          <!-- 提示 -->
          <div class="de">xxxxxx</div>
        </div>
        <!-- <input class="txt" type="password" /> -->
      </div>
    </div>
    <!-- 登录按钮 -->
    <div class="di">
      <div class="button" @click="deng">登录</div>
    </div>
    <!-- 注册 -->
    <div class="zhuce">
      <div class="zhuce1" @click="fn">注册账号</div>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  name: "HmDenglu",
  data() {
    return {
      username: "",
      password: "",
    };
  },
  methods: {
    deng() {
      //利用axios发送请求      http://interview-api-t.itheima.net/h5/user/login
      axios
        .post("http://interview-api-t.itheima.net/h5/user/login", {
          mobile: this.username,
          password: this.password,
        })
        .then((res) => {
          console.log(res);
          // 跳转路由
          this.$router.push("/home/article/recommend");
        });
    },
    // async deng() {
    //   const res = await axios({
    //     method: "post",
    //     url: "http://interview-api-t.itheima.net/h5/user/login",
    //     data: {
    //       mobile: this.username,
    //       password: this.password,
    //     },
    //   });
    //   localStorage.setItem("token", res.data.result.token);
    //   if (res.data.code === 200) {
    //     this.$router.push("/home/article/recommend");
    //   }
    // },

    fn() {
      // 跳转路由
      this.$router.push("/zhuce");
    },
  },
};
</script>

<style scoped lang="less">
.denglu {
  background-color: pink;
  height: 100%;
  width: 100%;

  .top {
    background-color: orange;
    height: 50px;
    width: 100%;
    display: flex;
    align-items: center;
    // text-align: center;
    //居中
    justify-content: center;
    margin-bottom: 40px;
  }
  .zhong {
    // height: 200px;
    padding-left: 5px;
    margin-bottom: 30px;
    .name {
      width: 99%;
      height: 60px;
      display: flex;
      margin-bottom: 30px;
      //底部边框
      border-bottom: 1px solid #999;
      .name1 {
        width: 100px;
        height: 50px;
        line-height: 22px;

        // text-align: center;
        // line-height: 50px;
      }

      .right {
        flex: 1;
        background-color: #8df;
        width: 100%;
        height: 100%;
        .txt {
          width: 97%;
          height: 40%;
        }
        .de {
          background-color: red;
          width: 100%;
          height: 40%;
        }
      }
    }
    .pass {
      width: 99%;
      height: 50px;
      display: flex;

      border-bottom: 1px solid #999;

      .pass1 {
        width: 100px;
        height: 50px;
        line-height: 22px;

        // text-align: center;
        // line-height: 50px;
      }

      .right {
        flex: 1;
        background-color: #8df;
        width: 100%;
        height: 100%;
        .txt {
          width: 97%;
          height: 40%;
        }
        .de {
          background-color: red;
          width: 100%;
          height: 40%;
        }
      }
    }
  }
  .di {
    width: 100%;
    height: 50px;
    display: flex;
    justify-content: center;

    .button {
      background-color: orange;
      width: 90%;
      height: 50px;
      display: flex;
      align-items: center;
      justify-content: center;
    }
  }
  .zhuce {
    // width: 100%;
    padding-right: 40px;
    .zhuce1 {
      //   width: 100%;
      /* 局右侧布局 */
      display: flex;
      justify-content: flex-end;
      color: rgb(101, 171, 199);
    }
  }
}
</style>
